
$(function() {
	
	$("#idcard").change(function(form) {		
		var body = { };
		body.idcard = $(this).val();
			
		var url = 'emp.php?do=Info.ajax_idcard';
		$.getJSON(url, body, function(json) {
			// alert($.toJSON(json));
			var password = _password(body.idcard);
			$("#password").val(password);
			
			$("#birthday").val(json.birthday);
			$("#sex").val(json.sex);
			
			$("#province").val(json.province);
			$("#city").val(json.city);
			$("#district").val(json.region);
			
			var address = json.province + json.city + json.region;
			$("#address").val(address);
		});
    });
});

function _password(s) {
	// alert(s.length);
	if (s.length == 15) {
		return s.substring(11, 15);
	}
	
	if (s.length == 18) {
		return s.substring(14, 18);
	}
	
	return '1234';
}
